package en.edu.zxj.rabbit.extensions.demo.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created with IntelliJ IDEA.
 * Description：
 *
 * @author: zxj
 * @date: 2024-09-21
 * @time: 22:16:46
 */
@Configuration
public class QosConfig {
    // 限流

    // 限流交换机
    @Bean("qosExchange")
    public DirectExchange qosExchange() {
        return ExchangeBuilder.directExchange("qosExchange").build();
    }

    // 限流队列
    @Bean("qosQueue")
    public Queue qosQueue() {
        return QueueBuilder.durable("qosQueue").build();
    }

    // 绑定队列和交换机
    @Bean("qosBind")
    public Binding qosBind(@Qualifier("qosExchange") DirectExchange exchange, @Qualifier("qosQueue") Queue queue) {
        return BindingBuilder.bind(queue).to(exchange).with("qos");
    }
}
